package com.langsheng.lsintell.ui.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.langsheng.lsintell.R;
import com.langsheng.lsintell.ui.widget.LSWaitingDialog;


/**
 * A simple {@link Fragment} subclass.
 */
public class LSBaseFragment extends Fragment {

    protected TextView titleName;
    protected TextView titleSubName;
    protected TextView titleBackBtn;
    protected TextView titleLeftFun;
    protected TextView titleRightFun1;
    protected TextView titleRightFun2;
    protected LinearLayout searchView;
    protected TextView searchName;
    private LSWaitingDialog waitingDialog;

    public LSBaseFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    protected LSWaitingDialog getWaitingDialog() {
        if (waitingDialog == null) {
            waitingDialog = new LSWaitingDialog(getActivity());
        }
        return waitingDialog;
    }

    protected View initTitleView(View titleView) {
        if (titleView == null) {
            return null;
        }
        titleName = (TextView) titleView.findViewById(R.id.tv_title_name);
        titleSubName = (TextView) titleView.findViewById(R.id.tv_title_sub_name);
        titleBackBtn = (TextView) titleView.findViewById(R.id.tv_title_back);
        titleLeftFun = (TextView) titleView.findViewById(R.id.tv_title_left_fun);
        titleRightFun1 = (TextView) titleView.findViewById(R.id.tv_title_right_fun1);
        titleRightFun2 = (TextView) titleView.findViewById(R.id.tv_title_right_fun2);
        return titleView;
    }

//    protected void initSearchBar(View view, final int type, final int mode) {
//        if (view == null) {
//            return;
//        }
//        searchView = (LinearLayout) view.findViewById(R.id.rl_search_view);
//        searchName = (TextView) view.findViewById(R.id.tv_search_name);
//        /**
//         * 点击最近联系人碎片中的搜索按钮进行跳转
//         */
//        searchView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent = new Intent(getActivity(), BASearchActivity.class);
//                intent.putExtra(BASearchActivity.SEARCH_TAG, type);
//                intent.putExtra(BASearchActivity.SEARCH_MODE, mode);
//                startActivity(intent);
//            }
//        });
//    }

    /**
     * @return true:不让activity响应返回事件
     */
    public boolean onBackPressed() {
        return false;
    }
}
